package com.example.carefree_server.mapper.m_managerMapper;

import com.example.carefree_server.entity.Department;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface DepartmentMapper {

    //    查询所有
    @Select("SELECT * FROM department")
    List<Department> getAllDepartments();

    //  查询详情（根据id）
    @Select("SELECT * FROM department where did=#{did}")
    Department findDepartmentById(String did);

    //  增加部门信息
    @Insert("INSERT INTO department (did,dname,dpassword,dmanager,dphone,problem,text) VALUES (#{did},#{dname},#{dpassword},#{dmanager},#{dphone},#{problem},#{text})")
    void insertDepartment(Department department);

    //  修改部门信息
    @Update("UPDATE department SET did=#{did},dname=#{dname},dpassword=#{dpassword},dmanager=#{dmanager},dphone=#{dphone},problem=#{problem},text=#{text} where did = #{did}")
    void updateDepartment(Department department);

    //  删除部门信息
    @Delete("Delete FROM department WHERE did =#{did}")
    void deleteDepartment(String did);


}
